<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //Shape形状类  父类
        //Circle圆类   子类
        class Shapes {
            constructor() {
                //初始值为-1，还未计算
                this.area = -1;
                this.len = -1;
            }
            showInfo() {
                console.log('面积' + this.area)
            }
        }
        class Circle extends Shapes {
            static pi = 3.14
            constructor(radius) {
                //在子类的构造方法中，必须先调用父类的构造方法
                //使用关键字super调用
                super();
                this.radius = radius;
            }
            getArea() {
                this.area = this.radius ** 2 * Circle.pi
            }
            getLen() {
                this.len = this.radius / 2 * Circle.pi * 2
            }
        }
        var a = new Circle(2);
        console.log(a);
    </script>
</body>

</html>